//
//  CuriousnessViewController.m
//  CoolFactsClass
//
//  Created by rimi on 16/7/12.
//  Copyright © 2016年 wangxinyao. All rights reserved.
//

#import "CuriousnessViewController.h"

@interface CuriousnessViewController ()
@property (nonatomic, strong) UIBarButtonItem * personalBtn;
// init
- (void)initializeDataSource;
- (void)initializeUserInterface;
@end

@implementation CuriousnessViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initializeDataSource];
    [self initializeUserInterface];
}

- (void)awakeFromNib{
    
}
#pragma mark - 初始化界面、数据
- (void)initializeDataSource{
    
}

- (void)initializeUserInterface{
    self.title = @"生活";
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:23]};
    // 添加领域按钮
    UIButton * leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0,0,32,30)];
    [leftBtn setImage:[UIImage imageNamed:@"add.png"] forState:UIControlStateNormal];
    
    [leftBtn addTarget:self action:@selector(addField) forControlEvents:UIControlEventTouchUpInside
     ];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:leftBtn];
    // 个人中心按钮
    self.navigationItem.rightBarButtonItem = self.personalBtn;
    
}

#pragma mark - Action

- (void)showRightViewOrHidden{
    MainViewController * mainVc = (MainViewController *)self.parentViewController.parentViewController;
    [mainVc showRightViewOrHidden];
}
- (void)addField{
    NSLog(@"添加领域");
}


#pragma mark - 懒加载
- (UIBarButtonItem *)personalBtn{
    if (!_personalBtn) {
        UIButton * rightButton = [[UIButton alloc] initWithFrame:CGRectMake(0,0,33,31)];
        [rightButton setImage:[UIImage imageNamed:@"headportrait.png"] forState:UIControlStateNormal];
        
        [rightButton addTarget:self action:@selector(showRightViewOrHidden) forControlEvents:UIControlEventTouchUpInside
         ];
        _personalBtn = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
    }
    return _personalBtn;
}
@end
